Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

63
Views
Discord.js "voiceStateUpdate" llamado dos veces

Estoy tratando de crear un canal temporal que funcione con los comandos "Slash". Ya casi llego, pero recibo un error al crear un segundo canal porque " voiceStateUpdate " se llama dos veces.

 else if (commandName === "createchannel") { var channelName = options.getString("channelname"); var rolesThatCanJoin = options.getRole("roles"); var state = options.getString("state"); var channel = interection.guild.channels.create(channelName, { type: "GUILD_VOICE" }).then((channel) => { channel.setParent("670691620844470320") createdChannelID = channel.id; interection.reply({ content: `**Channel named:** ${channelName}\n**Role that can join:** ${rolesThatCanJoin}\n**State:** ${state}`, ephemeral: true, }) client.on('voiceStateUpdate', (oldState, newState) => { var newChannelID = newState.channelId; if (newChannelID === createdChannelID) { console.log("User has joined voice channel with id " + newChannelID); } else { console.log("User has left"); channel.delete() } }); }); }

Consola:

 User has joined voice channel with id 936252040865284156 User has left User has joined voice channel with id 936252068568641576 User has joined voice channel with id 936252068568641576 User has left User has left Error: DiscordAPIError: Unknown Channel
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parece que cada vez que se ejecuta el comando, está llamando a client.on('voiceStateUpdate'... nuevamente, lo que agrega otro oyente. Esto hace que reciba el mismo evento varias veces. Le sugiero que mueva su client.on('voiceStateUpdate'... código a otra ubicación donde se llamará una vez, de la misma manera que maneja otros eventos como client.on('messageCreate'... o client.on('interactionCreate'...

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!